#!/bin/bash

# 确保目录存在
mkdir -p uploads results logs

# 检查.env文件是否存在，若不存在则创建
if [ ! -f .env ]; then
  echo "Creating default .env file..."
  cat > .env << EOL
# 应用配置
APP_PORT=5000
APP_HOST=0.0.0.0
APP_DEBUG=false

# 时区设置
TZ=Asia/Shanghai

# 字符编码
PYTHONIOENCODING=utf-8

# Docker 标记，用于应用内部检测是否在容器中运行
DOCKER_CONTAINER=true
EOL
fi

# 使用docker-compose启动服务
echo "Starting Word Compare service..."
docker-compose up -d --build

# 显示访问URL
echo ""
echo "Service started! Access the application at:"
echo "http://localhost:${APP_PORT:-5000}"
echo ""
echo "To view logs, run: docker-compose logs -f"
echo "To stop the service, run: docker-compose down" 